package org.handover.serviceImp;

import org.springframework.security.authentication.RememberMeAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class RememberMe {
    /**
     * 判断用户是否从Remember Me Cookie自动登录
     *
     * @return
     */
    public static boolean isRememberMeAuthenticated() {

        Authentication authentication = SecurityContextHolder.getContext()
                .getAuthentication();
        if (authentication == null) {
            return false;
        }

        return RememberMeAuthenticationToken.class
                .isAssignableFrom(authentication.getClass());
    }
}
